﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//Needed for using ArrayList
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //Create the array List so any method can access it
        //Array lists are dynamic and can grow
        ArrayList myList = new ArrayList();

        //Method runs when the form is loaded
        private void Form1_Load(object sender, EventArgs e)
        {
            missile mis1 = new missile(1000, 5000);
            missile mis2 = new missile(2000, 10000);

            myList.Add(mis1); //Add Object 1 to the array list
            myList.Add(mis2); //Add Object 2 to the array list
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Label label1 = new Label();
            Label label2 = new Label();

            label1.Text = "Speed: ";
            label2.Text = "Alt: ";

            label1.Location = new Point(110, 60);
            label2.Location = new Point(110, 90);

            //label1.Size = new Size(label1.PreferredWidth, label1.PreferredHeight);
            //label2.Size = new Size(label1.PreferredWidth, label1.PreferredHeight);

            foreach (missile mis in myList)
            {
                label1.Text += mis.Speed + " ";
                label2.Text += mis.Altitude + " "; 
            }

            //Adding controls (labels) during run time
            this.Controls.Add(label1);
            this.Controls.Add(label2);

 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            button1.Enabled = true;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            button1.Visible = false;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            button1.Visible = true;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            radar rad = new radar();
            rad.Name = "super XML rad";
            rad.Series = 3423487;
            XmlSerializer serializer = new XmlSerializer(typeof(radar));
            TextWriter textWriter = new StreamWriter(@"C:\Documents and Settings\jxo19\Desktop\WindowsFormsApplication3\WindowsFormsApplication3\radar.xml");
            serializer.Serialize(textWriter, rad);
            textWriter.Close();
        }

        private void button7_Click(object sender, EventArgs e)
        {

        }

     
    }
}
